<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>小程序设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header"><i class="fa fa-cog"></i> 小程序设置</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form" lay-filter="">
						<div class="layui-form-item">
							<label class="layui-form-label" style="width:130px">小程序名称：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[nickname]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['nickname']}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" style="width:130px">小程序图标：</label>
							<input type="hidden" name="info[headimg]" id="headimg" class="layui-input" value="{$info['headimg']}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="headimg" upload-preview="headimgPreview" onclick="uploader(this)">上传图片</button>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：400×400像素</div>
							<div id="headimgPreview" style="float:left;padding-top:10px;margin-left:160px;clear: both;">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info['headimg']}"/></div></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" style="width:130px">小程序APPID：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[appid]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['appid']}">
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">小程序ID，请在微信公众平台[开发>开发设置]中查找</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" style="width:130px">小程序AppSecret：</label>
							<div class="layui-input-inline" style="width:280px">
								<input type="text" name="info[appsecret]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['appsecret']}">
							</div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">小程序密钥，请在微信公众平台[开发>开发设置]中查找</div>
						</div>

						<div class="layui-form-item">
							<div class="layui-input-block" style="margin-left:160px;">
								<button class="layui-btn" lay-submit lay-filter="formsubmit">保 存</button>
								<button class="layui-btn layui-btn-primary" lay-submit lay-filter="formsubmit2">发布小程序</button>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
  </div>
	{include file="public/js"/}
	<script>
	layui.form.on('radio(freightfree)', function(data){
		if(data.value == '1'){
			$('#freightfreemoneyset').show();
		}else{
			$('#freightfreemoneyset').hide();
		}
	})
	layui.form.on('radio(comment)', function(data){
		if(data.value == '1'){
			$('#commentset').show();
		}else{
			$('#commentset').hide();
		}
	})
	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		if(field['info[appid]'] == ''){
			dialog('请填写小程序APPID',0);return;
		}
		if(field['info[appsecret]'] == ''){
			dialog('请填写小程序AppSecret',0);return;
		}
		$.post("{:url('set')}",field,function(data){
			dialog(data.msg,data.status,data.url);
		})
	})
	layui.form.on('submit(formsubmit2)', function(obj){
		var field = obj.field
		if(field['info[appid]'] == ''){
			dialog('请填写小程序APPID',0);return;
		}
		if(field['info[appsecret]'] == ''){
			dialog('请填写小程序AppSecret',0);return;
		}
		$.post("{:url('set')}",field,function(data){
			location.href = "{:url('index')}";
		})
	})
  </script>
	{include file="public/copyright"/}
</body>
</html>